package com.example.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class RedActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //去掉ActionBar
        ActionBar actionBar=getSupportActionBar();
        if(actionBar!=null){
            actionBar.hide();
        }
        //设置布局
        setContentView(R.layout.redactivity_layout);
        //获取Button实例
        Button close_bt = findViewById(R.id.close_bt);
        //获取TextView实例
        TextView red_act_content_tv = findViewById(R.id.red_act_content_tv);

        //获取intent实例
        Intent intent = getIntent();
        String username = intent.getStringExtra("username");
        int age = intent.getIntExtra("age",0);
        String msg = intent.getStringExtra("msg");
        // 给TextView设置显示内容
        red_act_content_tv.setText("username: "+username+" , age: "+age+" ,msg： "+msg);

        //按钮触发事件监听
        close_bt.setOnClickListener(v->{
            //关闭Activity
            finish();
        });

    }
}
